package com.romaremez.testuser.tests;

import com.romaremez.testuser.src.questionanswer.Answer;
import com.romaremez.testuser.src.questionanswer.AnswerCopyFactory;
import com.romaremez.testuser.src.questionanswer.OneAnswer;
import com.romaremez.testuser.src.questionanswer.AnswersArray;
import com.romaremez.testuser.src.questionanswer.MultipleAnswer;
import org.junit.Test;
     import static org.junit.Assert.*;

public class AnswerCopyFactoryTest {
    Answer answer;

    @Test
    public void testCreateNewAnswer() throws Exception {
        answer = null;
        Answer rez = AnswerCopyFactory.createNewAnswer(answer);
        assertNull("must be null", rez);
    }

    @Test
    public void testOneAnswerCopy() {
        answer = new OneAnswer("");
        Answer rezAnswer = AnswerCopyFactory.createNewAnswer(answer);
        String rez = rezAnswer.getClass().getName();
        String expected = "com.romaremez.testuser.src.questionanswer.OneAnswer";
        assertEquals("must be OneAnswer type", expected, rez);
    }

    @Test
    public void testMultipleAnswerCopy() {
        answer = new MultipleAnswer(new String[]{}, new String[]{});
        Answer rezAnswer = AnswerCopyFactory.createNewAnswer(answer);
        String rez = rezAnswer.getClass().getName();
        String expected = "com.romaremez.testuser.src.questionanswer.MultipleAnswer";
        assertEquals("must be MultipleAnswer type", expected, rez);
    }

    @Test
    public void testAnswersArrayCopy() {
        answer = new AnswersArray(new String[]{""});
        Answer rezAnswer = AnswerCopyFactory.createNewAnswer(answer);
        String rez = rezAnswer.getClass().getName();
        String expected = "com.romaremez.testuser.src.questionanswer.AnswersArray";
        assertEquals("must be AnswersArray type", expected, rez);
    }
}
